﻿@using System.Diagnostics
@{
    ViewData["Title"] = "资源管理";
}

<div class="panel panel-default">
    <div class="form-content">
        <div class="form-body">
            <div class="row" id="filter" data-toggle="form" data-field="Resource" data-grid="#grid" data-filterable="true" data-size="4,5,7">
                <input data-field="name,code,title" data-size="4,0,12" data-logic="or" data-operator="contains" />
                <button data-button="query"></button>
                <button data-button="clear">清除条件</button>
                <div class="pull-right" style="padding-right:15px;">
                    <button data-button="add" data-popup="Edit"></button>
                </div>
                <a data-button="advancedSearch" data-target="#filter_advancedSearch_grid"></a>
                <div id="filter_advancedSearch_grid" class="advancedSearch">
                    <div class="row">
                        <input data-field="name" data-label="资源名称" data-operator="contains" data-logic="or" />
                        <input data-field="title" data-label="资源显示名称" data-operator="contains" data-logic="or" />
                        <input data-field="content" data-label="资源内容" data-operator="contains" data-logic="or" />
                    </div>
                    <div class="row">
                        <input data-field="type" data-label="授权类型" data-role="kendoDropDownList" data-data="#:cache.authorizeType" />
                        <input data-field="resourceType" data-label="资源类型" data-role="kendoDropDownList" data-data="#:cache.resourceType" />
                        <input data-field="accessLevel" data-label="访问级别" data-role="kendoDropDownList" data-data="#:cache.accessLevel" />
                    </div>
                    <div class="row">
                        <input data-field="identityType" data-label="资源所有者类型" data-role="kendoDropDownList" data-data="#:cache.identityType" data-changed="#:IdentityType.onIdentityTypeChange" />
                        <input data-field="ownerId" data-label="资源所有者" type="hidden" />
                        <input data-field="ownerName" data-label="资源所有者" data-filterable="false" data-popup="SelectRole" data-popup-parameter="#:#_TemplatePopupParameter_SelectOwner" />

                        <input data-field="levelId" data-label="资源级别" type="hidden" />
                        <input data-field="levelName" data-label="资源级别" data-filterable="false" data-popup="SelectLevel" data-popup-parameter="#:#_TemplatePopupParameter_SelectLevel" />
                    </div>
                </div>
            </div>
            <div id="grid" data-toggle="grid" data-form="#filter" node="grid" data-related="#_PopupDetail" data-dblclicking="#:IdentityType.onGridSelecting">
                <div node="columns" node-type="array">
                    <span data-field="image" data-title="资源图标" data-type="image" data-hidden="true"></span>
                    <span data-field="_parent.title" data-title="父级资源"></span>
                    <span data-field="name" data-title="资源名称" data-width="25%"></span>
                    <span data-field="code" data-title="资源编号" data-width="10%"></span>
                    <span data-field="alias" data-title="资源别名" data-hidden="true"></span>
                    <span data-field="title" data-title="资源显示名称"></span>
                    <span data-field="type" data-title="授权类型" data-data-from="cache.authorizeType"></span>
                    <span data-field="resourceType" data-title="资源类型" data-template="#:data=>$.com.commonFormatter(cache.resourceType, data.resourceType)"></span>
                    <span data-field="identityType" data-title="资源所有者类型" data-template="#:data=>$.com.commonFormatter(cache.identityType, data.identityType)"></span>
                    <span data-field="content" data-title="资源内容" data-width="20%"></span>
                    <span data-field="description" data-title="备注说明" data-hidden="true"></span>
                    <span data-field="accessLevel" data-title="访问级别" data-template="#:data=>$.com.commonFormatter(cache.accessLevel, data.accessLevel)"></span>
                    <span data-field="level.name" data-title="资源级别" data-hidden="true"></span>
                    <span data-field="state" data-title="状态" data-data-from="cache.dataState" data-hidden="true"></span>
                    <span data-field="createdOn" data-title="创建时间" data-type="datetime" data-hidden="true"></span>
                </div>
                <span node="dataSource">
                    <span node="transport">
                        <span node="read" data-url="/odata/Resources?$expand=parent($select=id,name,title),level($select=id,name)">
                        </span>
                    </span>
                    <span node="sort" data-field="code" data-dir="asc"></span>
                </span>
            </div>
        </div>
    </div>
</div>

<div id="_PopupDetail" data-toggle="popup" data-type="Detail" data-title="资源信息" data-size="hd">
    <div class="popup-content" data-toggle="form" data-field="Detail" data-detailable="true" data-size="12,4,8">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <div data-field="image" data-label="资源图片" data-type="img" data-business-type="Resource" data-single="true"></div>
                    <span data-field="_parent.title" data-label="父级资源"></span>
                    <span data-field="name" data-label="资源名称"></span>
                    <span data-field="code" data-label="资源编号"></span>
                    <span data-field="alias" data-label="资源别名"></span>
                    <span data-field="title" data-label="资源显示名称"></span>
                    <span data-field="type" data-label="授权类型" data-data-from="cache.authorizeType"></span>
                    <span data-field="resourceType" data-label="资源类型" data-formatter="#:el=>$.com.commonFormatter(cache.resourceType, el.options.value)"></span>
                    <span data-field="identityType" data-label="资源所有者类型" data-formatter="#:el=>$.com.commonFormatter(cache.identityType, el.options.value)"></span>
                    <span data-field="ownerName" data-label="资源所有者"></span>
                    <span data-field="content" data-label="资源内容"></span>
                    <span data-field="accessLevel" data-label="访问级别" data-formatter="#:el=>$.com.commonFormatter(cache.accessLevel, el.options.value)"></span>
                    <span data-field="level.name" data-label="资源级别"></span>
                    <span data-field="state" data-label="状态" data-data-from="cache.dataState"></span>
                    <span data-field="description" data-label="备注说明"></span>
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="edit" data-popup="Edit"></button>
            <button data-button="close"></button>
        </div>
    </div>
</div>

<div id="_PopupEdit" data-toggle="popup" data-type="Edit" data-title="资源信息" data-related="#filter" data-size="hd" data-opened="#:IdentityType.onEditOpened">
    <div class="popup-content" data-toggle="form" data-field="Edit" data-editable="true" data-url="/api/Resources" data-size="12,3,8">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-body">
                    <input data-field="parentId" data-label="父级资源" type="hidden" />
                    <input data-field="_parent.title" data-label="父级资源" data-popup="SelectResource" data-popup-parameter="#:#_TemplatePopupParameter_SelectParentResource" />
                    <input data-field="name" data-label="资源名称" required />
                    <input data-field="code" data-label="资源编号" />
                    <input data-field="alias" data-label="资源别名" />
                    <input data-field="title" data-label="资源显示名称" required />
                    <span data-field="type" data-label="授权类型" required type="radio" data-with-group="true" data-data="#:cache.authorizeType" data-value="Internal"></span>
                    <span data-field="resourceType" data-label="资源类型" required type="radio" data-with-group="true" data-data="#:cache.resourceType" data-value="Page"></span>
                    <span data-field="identityType" data-label="资源所有者类型" required type="radio" data-with-group="true" data-data="#:cache.identityType" data-value="Role" data-changed="#:IdentityType.onIdentityTypeChange"></span>
                    <input data-field="ownerId" data-label="资源所有者" type="hidden" />
                    <input data-field="ownerName" data-label="资源所有者" data-popup="SelectRole" data-popup-parameter="#:#_TemplatePopupParameter_SelectOwner" />
                    <textarea data-field="content" data-label="资源内容" required rows="3" data-multiple="true"></textarea>
                    <textarea data-field="description" data-label="备注说明" rows="3" data-multiple="true"></textarea>
                    <span data-field="accessLevel" data-label="访问级别" required type="radio" data-size="12,3,9" data-with-group="true" data-data="#:cache.accessLevel" data-value="Internal"></span>
                    <input data-field="levelId" data-label="资源级别" type="hidden" />
                    <input data-field="level.name" data-label="资源级别" data-popup="SelectLevel" data-popup-parameter="#:#_TemplatePopupParameter_SelectLevel" />
                    <span data-field="state" data-label="状态" required type="radio" data-with-group="true" data-data="#:cache.dataState" data-value="Available"></span>
                    <input data-field="image" data-label="资源图片" data-with-attachments="true" data-business-type="Resource" data-single="true" type="file" data-role="kendoUpload" data-file-size="1024" data-file-extension=".jpg,.jpeg,.png" />
                </div>
            </div>
        </div>
        <div class="popup-footer text-right">
            <button data-button="post" data-success-text="新增成功"></button>
            <button data-button="put" data-success-text="保存成功"></button>
            <button data-button="delete" data-success-text="删除成功"></button>
            <button data-button="close"></button>
        </div>
    </div>
</div>

<!--弹出框参数传递-->
<span id="_TemplatePopupParameter_SelectParentResource" node="popupParameter" data-title="选择父级资源">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="parentId" data-target="id"></span>
        <span data-transfer="int,out" data-source="_parent.title" data-target="title"></span>
    </span>
</span>

<span id="_TemplatePopupParameter_SelectOwner" node="popupParameter">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="ownerId" data-target="id"></span>
        <span data-transfer="int,out" data-source="ownerName" data-target="alias"></span>
    </span>
</span>

<span id="_TemplatePopupParameter_SelectLevel" node="popupParameter" data-title="选择资源级别">
    <span node="parameter" node-type="array">
        <span data-transfer="out" data-source="levelId" data-target="id"></span>
        <span data-transfer="int,out" data-source="level.name" data-target="name"></span>
    </span>
</span>

<partial name="../Popups/SelectUser" />
<partial name="../Popups/SelectRole" />
<partial name="../Popups/SelectGroup" />
<partial name="../Popups/SelectLevel" />
<partial name="../Popups/SelectResource" />
<script src=~/js/identityType.js asp-append-version="true"></script>